use crate::model;

pub enum FindBy<'a> {
    ID(&'a str),
    Email(&'a str),
}

pub struct Find<'a> {
    pub by: FindBy<'a>,
    pub status: Option<model::user::Status>,
    pub role: Option<model::user::Role>,
}

impl<'a> Find<'a> {
    fn new(by: FindBy<'a>) -> Self {
        Self {
            by,
            status: None,
            role: None,
        }
    }
    pub fn with_id(id: &'a str) -> Self {
        Self::new(FindBy::ID(id))
    }

    pub fn with_email(email: &'a str) -> Self {
        Self::new(FindBy::Email(email))
    }

    pub fn admin(email: &'a str) -> Self {
        Self {
            by: FindBy::Email(email),
            status: Some(model::user::Status::Actived),
            role: Some(model::user::Role::Admin),
        }
    }
    pub fn user(email: &'a str) -> Self {
        Self {
            by: FindBy::Email(email),
            status: None,
            role: Some(model::user::Role::Member),
        }
    }
}

#[derive(Default)]
pub struct List<'a> {
    pub pagination: super::Pagination,
    pub email: Option<&'a str>,
    pub status: Option<model::user::Status>,
    pub role: Option<model::user::Role>,
    pub order: Option<&'a str>,
}
